package com.lh.myssm.trans;

import com.lh.myssm.basedao.ConnUtil;

import java.sql.Connection;
import java.sql.SQLException;

public class TransactionManager {

    public static void beginTrans() throws SQLException {
        ConnUtil.getConnection().setAutoCommit(false);

    }

    public static void commiTrans() throws SQLException {
        Connection connection = ConnUtil.getConnection();
        connection.commit();
        ConnUtil.closeConnection();
    }

    public static void rollback() throws SQLException {
        Connection connection = ConnUtil.getConnection();
        connection.rollback();
        ConnUtil.closeConnection();
    }

}
